function showCard(theCard){
	
	switch(theCard){
		case 1:	document.getElementById("card_2").style.top=0;    //rollover card 1
				document.getElementById("card_3").style.top=-60;
				document.getElementById("card_4").style.top=-120;
				break;
		case 2:	document.getElementById("card_2").style.top=-60;    //rollover card 2
				document.getElementById("card_3").style.top=-60;
				document.getElementById("card_4").style.top=-120;
				break;
		case 3:	document.getElementById("card_2").style.top=-60;     //rollover card 3
				document.getElementById("card_3").style.top=-120;
				document.getElementById("card_4").style.top=-120;
				break;
		case 4:	document.getElementById("card_2").style.top=-60;
				document.getElementById("card_3").style.top=-120;
				document.getElementById("card_4").style.top=-180;
				break;
	}
}

function hideCard(theCard){
	document.getElementById("card_2").style.top=-60;
	document.getElementById("card_3").style.top=-120;
	document.getElementById("card_4").style.top=-180;
}

var theImages=null;

function swapImage(imageId,newImage){
	var oldImage=document.getElementById(imageId).src;
	var imageRestore=oldImage.substring(oldImage.lastIndexOf("/")+1);
	document.getElementById(imageId).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+newImage;
	if(theImages==null){
		theImages=new Array();
	}
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			theImages[i][1]=imageRestore;
			return(true);
		}
	}
	theImages[theImages.length]=[imageId,imageRestore];
}

function restoreImage(imageId){
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			var oldImage=document.getElementById(imageId).src;
			document.getElementById(imageId).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+theImages[i][1];
			return(true);
		}
	}
}

function setRestoreImage(imageId,restoreImage){
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			theImages[i][1]=restoreImage;
			return(true);
		}
	}
	theImages[theImages.length]=[imageId,restoreImage]
}

function restoreAll(){
	for(var i=0;i<theImages.length;i++){
		var oldImage=document.getElementById(theImages[i][0]).src;
		document.getElementById(theImages[i][0]).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+theImages[i][1];
	}
}

function preLoadImage(theImage){
	var newImage=new Image();
	newImage.src=theImage;
}

function preLoadImages(imageArray){
	for(var i=0;i<imageArray.length;i++){
		var newImage=new Image();
		newImage.src=imageArray[i];
	}
}
function preloadImage(theImage){
	var newImage=new Image();
	newImage.src=theImage;
}

function preloadImages(imageArray){
	for(var i=0;i<imageArray.length;i++){
		var newImage=new Image();
		newImage.src=imageArray[i];
	}
}

// These are the variables; you can change these if you want
var expDays = 365;  // How many days to remember the setting
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

// Function to get the settings of the user
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

// Function to get the settings of the user
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

// Function to remember the settings
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	//"; expires=" + exp.toGMTString() +
	"; path=/" +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// Function to remove the settings
function DeleteCookie (name) {
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// This function is used when the user gives his selection
function doRefresh(){
	location.reload();
}

function fireEvent(element,event) {
   if (document.createEvent) {
       // dispatch for firefox + others
       var evt = document.createEvent("HTMLEvents");
       evt.initEvent(event, true, true ); // event type,bubbling,cancelable
       return !element.dispatchEvent(evt);
   } else {
       // dispatch for IE
       var evt = document.createEventObject();
       return element.fireEvent('on'+event,evt);
   }
}

function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
	} else { 
		window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
			} 
			func(); 
		} 
	} 
} 

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

/*

SmoothMovement.js

Facilitates smooth movement effects

Created by Stephen Morley - http://code.stephenmorley.org/ - and released under
the terms of the CC0 1.0 Universal legal code:

http://creativecommons.org/publicdomain/zero/1.0/legalcode

*/

/* Creates a SmoothMovement. A SmoothMovement produces integer position values
 * representing movement towards a target position, with a maximum acceleration
 * or deceleration of one distance unit per time unit squared. The parameters
 * are:
 *
 * position - the initial position - this optional parameter defaults to zero
 * target   - the target position - this optional parameter defaults to the
 *            value of the position parameter
 */
function SmoothMovement(position, target){

  // initialise the position, target, velocity, and animation interval
  this.position          = (position == undefined ? 0             : position);
  this.target            = (target   == undefined ? this.position : target);
  this.velocity          = 0;
  this.animationInterval = null;

}

/* Updates the position an velocity for this SmoothMovement, and returns the
 * new position.
 */
SmoothMovement.prototype.update = function(){

  // check whether the velocity is negative
  if (this.velocity < 0){

    // check whether we must decelerate or can accelerate
    if (this.target > this.position - this.velocity * (this.velocity - 1) / 2){

      // we must decelerate to avoid overshooting, so decrease the speed
      this.velocity ++;

    }else if (this.target <=
        this.position - (this.velocity - 1) * (this.velocity - 2) / 2){

      // we can accelerate without overshooting, so increase the speed
      this.velocity --;

    }

  }else{

    // check whether we must decelerate or can accelerate
    if (this.target < this.position + this.velocity * (this.velocity + 1) / 2){

      // we must decelerate to avoid overshooting, so decrease the speed
      this.velocity--;

    }else if (this.target >=
        this.position + (this.velocity + 1) * (this.velocity + 2) / 2){

      // we can accelerate without overshooting, so increase the speed
      this.velocity++;

    }

  }

  // update the position
  this.position += this.velocity;

  // return the new position
  return this.position;

}

/* Returns true if this SmoothMovement has stopped, and false otherwise. Note
 * that this means that both the velocity and acceleration are zero (or
 * equivalently, that the velocity is zero and the position is at the target).
 */
SmoothMovement.prototype.hasStopped = function(){

  // return whether we have stopped
  return (this.position == this.target && this.velocity == 0);

}

/* Animates this SmoothMovement by calling the update function repeatedly until
 * the SmoothMovement has stopped. The parameters are:
 *
 * interval       - the interval between updates, in milliseconds
 * updateListener - a function to call after each update. This function is
 *                  passed the new position and the SmoothMovement as its
 *                  first and second parameters.
 * stopListener   - a function to call when the SmoothMovement has stopped. This
 *                  function is passed the SmoothMovement as its parameter. This
 *                  parameter is optional.
 */
SmoothMovement.prototype.animate = function(
    interval, updateListener, stopListener){

  // clear any current animation interval
  if (this.animationInterval) window.clearInterval(this.animationInterval);

  // create the new animation interval
  this.animationInterval = window.setInterval(
      this.createAnimationClosure(updateListener, stopListener), interval);

}

/* Creates a closure for use in the animate function. This function is not
 * intended to be used elsewhere. The parameters are:
 *
 * updateListener - a function to call after each update
 * stopListener   - a function to call when the SmoothMovement has stopped
 */
SmoothMovement.prototype.createAnimationClosure = function(
    updateListener, stopListener){

  // store a reference to the 'this' object
  var thisObject = this;

  // return the animation closure
  return function(){

    // update the SmoothMovement
    thisObject.update();

    // call the update listener
    updateListener(thisObject.position, thisObject);

    // check whether the SmoothMovement has stopped
    if (thisObject.hasStopped()){

      // clear the animation interval
      window.clearInterval(thisObject.animationInterval);
      thisObject.animationInterval = null;

      // call the stop listener if one was supplied
      if (stopListener) stopListener(thisObject);

    }

  }

}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };